local skel = fk.CreateSkill {
  name = "emo__qianju",
  tags = {Skill.Compulsory},
}

Fk:loadTranslationTable{
  ["emo__qianju"] = "千驹",
  [":emo__qianju"] = "锁定技，当你使用牌时，若你本回合使用牌数等于X，你摸X张牌（X为你体力值的两倍）。",

  ["@[emo__qianju]"] = "千驹",

  ["$emo__qianju1"] = "虎豹骑倾巢而动，安有不胜之理？",
  ["$emo__qianju2"] = "任尔等固若金汤，虎豹骑可破之！",
}

Fk:addQmlMark{
  name = "emo__qianju", -- 宝宝标记
  how_to_show = function(name, value, p)
    if value == 0 or value == nil then return " " end
    return p:getMark("emo__qianju-turn") .. "/" .. p.hp * 2
  end,
}

skel:addEffect(fk.CardUsing, {
  anim_type = "drawcard",
  can_trigger = function (self, event, target, player, data)
    return target == player and player:hasSkill(skel.name) and player:getMark("emo__qianju-turn") == player.hp * 2
  end,
  on_use = function (self, event, target, player, data)
    player:drawCards(player.hp * 2, skel.name)
  end,
})

skel:addEffect(fk.CardUsing, {
  anim_type = "drawcard",
  can_refresh = function (self, event, target, player, data)
    return target == player
  end,
  on_refresh = function (self, event, target, player, data)
    player.room:addPlayerMark(player, "emo__qianju-turn")
  end,
})

skel:addAcquireEffect(function (self, player)
  player.room:setPlayerMark(player, "@[emo__qianju]", 1)
  player.room:setPlayerMark(player, "emo__qianju-turn", #player.room.logic:getEventsOfScope(GameEvent.UseCard, 999, function(e)
    local use = e.data
    return use.from == player
  end, Player.HistoryTurn))
end)

skel:addLoseEffect(function (self, player, is_death)
  player.room:setPlayerMark(player, "@[emo__qianju]", 0)
end)

return skel
